package com.haochu.novel.util;

import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.PopupWindow;

import com.example.testnovel.R;

/**
 * @author fuhuichao
 * 2017年7月5日17:33:35
 * 动画工具类
 */
public class AnimationUtil {

	/**
	 * 显示menubar的动画
	 */
	public static void showMenuBarAnimate(View view, Context context){
		Animation anim = AnimationUtils.loadAnimation(context, R.anim.show_menubar);
		view.startAnimation(anim);
	}
	
	/**
	 * 隐藏menubar的动画
	 */
	public static void hideMenuBarAnimate(View view, Context context, final PopupWindow popup){
		Animation anim = AnimationUtils.loadAnimation(context, R.anim.hide_menubar);
		anim.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation arg0) {
			}
			
			@Override
			public void onAnimationRepeat(Animation arg0) {
			}
			
			@Override
			public void onAnimationEnd(Animation arg0) {
				// 动画结束后回调
				popup.dismiss();
			}
		});
		view.startAnimation(anim);
	}
	
	
}
